﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Admin.Areas.Administration.Common.MenuManager;
using Admin.Models;
using Microsoft.VisualStudio.TestTools.UnitTesting;
//using Admin.App_Start;

namespace TestAdmin
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMenu()
        {
            List<TblMenuAdmin> list = new List<TblMenuAdmin>();
            list = MenuManagement.MenuFromXml;
            foreach (TblMenuAdmin item in list)
            {
                Console.WriteLine(item.LinkText);
            }
            Console.WriteLine("kết thúc test");
        }

        [TestMethod]//goi menu theo cach de quy
        //public void LoadMenu()
        //{
        //    //Initize.ManageMenuAdmin();
        //    List<TblMenuAdmin> listmenu = new List<TblMenuAdmin>();
        //   listmenu = MenuManagement.Load_menu();
        //    //Console.WriteLine(listmenu.Count.ToString(CultureInfo.InvariantCulture));
        //    TryLoadMenu(0, listmenu);

        //}

        public void TryLoadMenu(int i, List<TblMenuAdmin> list )
        {
            foreach (TblMenuAdmin item in list)
            {
                if (item.ParentId == i)
                {
                    Console.WriteLine(item.LinkText +"--- "+ item.Display);
                    if (MenuManagement.CheckMenuHasChild(item.MenuId))
                    {
                        Console.WriteLine("-- Xuất hiện menu con --");
                        TryLoadMenu(Convert.ToInt32(item.MenuId), list);
                    }
                }
            }
        }

     
    }
}
